


import React,{ Component} from 'react';
import { Table,Button } from 'antd';


const rowSelection = {

}
class SelectCheckBox  extends Component {
    constructor(props) {
        super(props);
        this.state = {
            selectedRowKeys: [],
            array: ['ni','shi','wo','de']
        }
    }
    onSelectChange(selectedRowKeys){
        console.log('selectedRowKeys changed: ', selectedRowKeys);
        this.setState({ selectedRowKeys });
        //console.log('selectedRowKeys1',selectedRowKeys);
        console.log('selectedRowKeys',this.state.selectedRowKeys);
    }
    componentDidMount() {

    }
    handleEvent() {
        //let url = `${GAPIURL}/wo/dataExport/workorderExport/kf_1000/kf_1000_006ed17e-031c-45b0-9652-7fec9bbbc304?woIds=${woIds}`;
        var indexs = this.state.selectedRowKeys;
        console.log('indexs',indexs);
        var woIds = '';
        indexs.forEach((item,index) => {
            console.log('item',item);
            console.log('index',index);
            //var woIds = this.state.array[index].woId;
            woIds += this.state.array[item]+',';
            //console.log('woIds',woIds);
        })

        // var split = woIds.split('');
        // console.log('分割之后',split);
        // console.log('分割之前',woIds);
        //
        // var pop = split.pop();
        // console.log('pop之后',pop);
        // console.log('pop之钱',split);
        //
        // woIds = split.join('');
        // console.log('woIds',woIds);

        var split = woIds.split('');
        var pop = split.pop();
        var join = split.join('');
        console.log('join',join);

        //var pop = woIds.split('').pop();
       // var woId = woIds.split('').join('');
        //console.log('woIds',woId);
    }
    render() {
        const columns = [{
            title: '姓名',
            dataIndex: 'name',
            key: 'name',
        },{
            title: '年龄',
            dataIndex: 'age',
            key: 'age',
        },{
            title: '地址',
            dataIndex: 'address',
            key: 'address'
        }]

        const data = [];
        for( let i=0;i<6;i++) {
            data.push({
                key: i,
                name: `天下${i}`,
                age: 18,
                address: `北京市${i}`,
            })
        }
        const selectedRowKeys = this.state.selectedRowKeys;
        const rowSelection = {
            selectedRowKeys,
            onChange: this.onSelectChange.bind(this),
        }
        return(
            <div>
                <Table rowSelection={ rowSelection } dataSource={ data } columns={columns} />
                <a onClick={()=> this.handleEvent()} style={{ color: 'red'}}>
                    点击
                </a>

            </div>
        )
    }
}
export default SelectCheckBox